hide keyboard flutter

98

FocusScope.of(context).unfocus()
class _HomeState extends State<Home> {
 var currentFocus;
    
 unfocus() {
    currentFocus = FocusScope.of(context);

    if (!currentFocus.hasPrimaryFocus) {
      currentFocus.unfocus();
    }
  }
  
Widget build(BuildContext context) {
    return GestureDetector(
      onTap: unfocus,
      child: Scaffold(...)
      )
     }
/// Hide the soft keyboard.
void hideKeyboard(BuildContext context) {
  FocusScope.of(context).requestFocus(FocusNode());
}
resizeToAvoidBottomInset: false,

Comments

Submit
0 Comments